<template>
  <div class="Users">
    <ul>
      <li>
        <div>我的头像</div>
        <div><img :src="User.avatar" alt=""></div>
      </li>
      <li>
        <div>昵称</div>
        <div><span>{{User.nickname}}</span></div>
      </li>
      <li>
        <div>手机号</div>
        <div @click="go('Binding')"><span>{{User.user_phone}}</span> <i class="iconfont icon-jinru" v-if="isuser_phonee"></i></div>
      </li>
      <!--<li>-->
        <!--<div>收货地址</div>-->
        <!--<div @click="go('Address')"><span>{{user_address}}</span> <i class="iconfont icon-jinru"></i></div>-->
      <!--</li>-->
    </ul>
  </div>
</template>

<script>
  export default {
    name: "index",
    data: function () {
      return {
        User: {
          avatar:'',
          nickname:'',
          user_phone:''
        },
        // user_address:{},
        isuser_phonee:false
      }
    },
    mounted:function(){
      this.updata(this.$Login.oauth_token)
    },
    methods: {
      updata: function (data) {
        this.$axios.user_info(data).then(res => {
          this.User = res.data.qing_data.user_info
          if(res.data.qing_data.user_info.user_phone&&res.data.qing_data.user_info.user_phone!==''){
            this.User.user_phone = res.data.qing_data.user_info.user_phone
          }else{
            this.isuser_phonee = true
            this.User.user_phone = '绑定手机号'
          }
          // if(res.data.qing_data.user_address){
          //   this.user_address = res.data.qing_data.user_address.province_name+res.data.qing_data.user_address.city_name+res.data.qing_data.user_address.distinct_name
          // }else{
          //   this.user_address = '编辑地址'
          // }
        })
      },
      go: function (name, obj) {
        if(name==='Binding'&&!this.isuser_phonee){
          return
        }
        this.$router.push({
          name: name,
          query: obj || {}
        })
      },
    }
  }
</script>

<style scoped>
  @import "../../assets/css/views/Users/index.css";
</style>
